-
-
Notifications
You must be signed in to change notification settings - Fork 989
fix(cli-v3): allow disabling source-map-support to prevent OOM with Sentry #2989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(cli-v3): allow disabling source-map-support to prevent OOM with Sentry #2989
Conversation
🦋 Changeset detectedLatest commit: ed41f0a The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis pull request refactors source map support across multiple worker entry points by centralizing configuration into a new utility module. A new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import { installSourceMapSupport } from "../utilities/sourceMaps.js"; | ||
|
|
||
| installSourceMapSupport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Missing imports in managed-run-worker.ts cause runtime errors
The PR removed import statements for env, normalizeImportPath, VERSION, and promiseWithResolvers from managed-run-worker.ts, but these symbols are still used in the code, causing undefined reference errors at runtime.
Click to expand
Missing imports and their usages:
-
env(fromstd-env) - used at lines 177, 179:url: env.TRIGGER_OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318", diagLogLevel: (env.TRIGGER_OTEL_LOG_LEVEL as TracingDiagnosticLogLevel) ?? "none",
-
normalizeImportPath(from../utilities/normalizeImportPath.js) - used at lines 173, 449, 457:const { config, handleError } = await importConfig(normalizeImportPath(workerManifest.configPath)); await import(normalizeImportPath(workerManifest.initEntryPoint)); await import(normalizeImportPath(taskManifest.entryPoint));
-
VERSION(from../version.js) - used at lines 186, 187:const otelTracer: Tracer = tracingSDK.getTracer("trigger-dev-worker", VERSION); const otelLogger: Logger = tracingSDK.getLogger("trigger-dev-worker", VERSION);
-
promiseWithResolvers(from@trigger.dev/core/utils) - used at line 626:const { promise, resolve } = promiseWithResolvers<void>();
Impact:
The managed worker will crash immediately when it tries to access these undefined symbols, preventing any task execution in production environments.
Recommendation: Add back the missing imports:
import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";Was this helpful? React with 👍 or 👎 to provide feedback.
| import { installSourceMapSupport } from "../utilities/sourceMaps.js"; | ||
|
|
||
| installSourceMapSupport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Missing imports in dev-run-worker.ts cause runtime errors
The PR removed import statements for env, normalizeImportPath, VERSION, and promiseWithResolvers from dev-run-worker.ts, but these symbols are still used in the code, causing undefined reference errors at runtime.
Click to expand
Missing imports and their usages:
-
env(fromstd-env) - used at lines 180, 197, 201:const manifestContents = await readFile(env.TRIGGER_WORKER_MANIFEST_PATH!, "utf-8"); url: env.TRIGGER_OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318", diagLogLevel: (env.TRIGGER_OTEL_LOG_LEVEL as TracingDiagnosticLogLevel) ?? "none",
-
normalizeImportPath(from../utilities/normalizeImportPath.js) - used at lines 169, 457, 465:const configModule = await import(normalizeImportPath(configPath)); await import(normalizeImportPath(workerManifest.initEntryPoint)); await import(normalizeImportPath(taskManifest.entryPoint));
-
VERSION(from../version.js) - used at lines 206, 207:const otelTracer: Tracer = tracingSDK.getTracer("trigger-dev-worker", VERSION); const otelLogger: Logger = tracingSDK.getLogger("trigger-dev-worker", VERSION);
-
promiseWithResolvers(from@trigger.dev/core/utils) - used at line 637:const { promise, resolve } = promiseWithResolvers<void>();
Impact:
The dev worker will crash immediately when it tries to access these undefined symbols, preventing any task execution in development environments.
Recommendation: Add back the missing imports:
import { env } from "std-env";
import { normalizeImportPath } from "../utilities/normalizeImportPath.js";
import { VERSION } from "../version.js";
import { promiseWithResolvers } from "@trigger.dev/core/utils";Was this helpful? React with 👍 or 👎 to provide feedback.
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/cli-v3/src/entryPoints/dev-run-worker.ts`:
- Around line 104-105: The process.title assignment uses a template literal that
includes a newline and spaces before the closing "})", producing an unintended
multiline process title; fix this in the process.title = `trigger-dev-run-worker
(${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`; statement by
moving the closing brace and backtick onto the same line as the template
expression so no newline or extra spaces are included (locate the assignment to
process.title and the getEnvVar call to update).
In `@packages/cli-v3/src/utilities/sourceMaps.test.ts`:
- Around line 2-61: The tests violate the no-mocking policy: remove
vi.mock("source-map-support") and any vi.fn() stubs for
process.setSourceMapsEnabled from
packages/cli-v3/src/utilities/sourceMaps.test.ts and instead refactor
installSourceMapSupport to accept its dependencies (e.g., a sourceMapSupport
object with an install method and an optional setSourceMapsEnabled function) or
to expose pure helper functions for the decision logic; update the tests to call
those pure functions or pass real dependency objects (or use an integration test
hitting the real source-map-support) and assert behavior without creating mocks
or spies against source-map-support or process.setSourceMapsEnabled.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.changeset/fix-sentry-oom-2920.mdpackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.tspackages/cli-v3/src/utilities/sourceMaps.test.tspackages/cli-v3/src/utilities/sourceMaps.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead
**/*.{ts,tsx}: Always import tasks from@trigger.dev/sdk, never use@trigger.dev/sdk/v3or deprecatedclient.defineJobpattern
Every Trigger.dev task must be exported and have a uniqueidproperty with no timeouts in the run function
Files:
packages/cli-v3/src/utilities/sourceMaps.tspackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/utilities/sourceMaps.test.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Import from
@trigger.dev/coreusing subpaths only, never import from root
Files:
packages/cli-v3/src/utilities/sourceMaps.tspackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/utilities/sourceMaps.test.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries
Files:
packages/cli-v3/src/utilities/sourceMaps.tspackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/utilities/sourceMaps.test.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier before committing
Files:
packages/cli-v3/src/utilities/sourceMaps.tspackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/utilities/sourceMaps.test.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
{packages,integrations}/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Add a changeset when modifying any public package in
packages/*orintegrations/*usingpnpm run changeset:add
Files:
packages/cli-v3/src/utilities/sourceMaps.tspackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/utilities/sourceMaps.test.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use vitest for all tests in the Trigger.dev repository
Files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptivedescribeanditblocks
Tests should avoid mocks or stubs and use the helpers from@internal/testcontainerswhen Redis or Postgres are needed
Use vitest for running unit tests
**/*.test.{ts,tsx,js,jsx}: Use vitest exclusively for testing and never mock anything - use testcontainers instead
Place test files next to source files with naming pattern: source file (e.g.,MyService.ts) →MyService.test.ts
Files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use testcontainers helpers (
redisTest,postgresTest,containerTest) from@internal/testcontainersfor Redis/PostgreSQL testing instead of mocks
Files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
🧠 Learnings (24)
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks
Applied to files:
.changeset/fix-sentry-oom-2920.mdpackages/cli-v3/src/utilities/sourceMaps.tspackages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx} : Always import tasks from `trigger.dev/sdk`, never use `trigger.dev/sdk/v3` or deprecated `client.defineJob` pattern
Applied to files:
packages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
Applied to files:
packages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use logger methods (debug, log, info, warn, error) from `trigger.dev/sdk/v3` for structured logging in tasks
Applied to files:
packages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Applied to files:
packages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.tspackages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Import from `trigger.dev/core` using subpaths only, never import from root
Applied to files:
packages/cli-v3/src/entryPoints/dev-index-worker.tspackages/cli-v3/src/entryPoints/managed-index-worker.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Place test files next to source files with naming pattern: source file (e.g., `MyService.ts`) → `MyService.test.ts`
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to **/*.{test,spec}.{ts,tsx} : Use vitest for all tests in the Trigger.dev repository
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest exclusively for testing and never mock anything - use testcontainers instead
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for running unit tests
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Test files should live beside the files under test and use descriptive `describe` and `it` blocks
Applied to files:
packages/cli-v3/src/utilities/sourceMaps.test.ts
📚 Learning: 2025-11-26T14:40:07.146Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 2710
File: packages/schema-to-json/package.json:0-0
Timestamp: 2025-11-26T14:40:07.146Z
Learning: Node.js 24+ has native TypeScript support and can execute .ts files directly without tsx or ts-node for scripts that use only erasable TypeScript syntax (type annotations, interfaces, etc.). The trigger.dev repository uses Node.js 24.11.1+ and scripts like updateVersion.ts can be run with `node` instead of `tsx`.
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
📚 Learning: 2025-10-08T11:48:12.327Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2593
File: packages/core/src/v3/workers/warmStartClient.ts:168-170
Timestamp: 2025-10-08T11:48:12.327Z
Learning: The trigger.dev runners execute only in Node 21 and 22 environments, so modern Node.js APIs like AbortSignal.any (introduced in v20.3.0) are supported.
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to **/*.{ts,tsx} : Every Trigger.dev task must be exported and have a unique `id` property with no timeouts in the run function
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Use `trigger.dev/redis-worker` for background job and worker system needs in the webapp and run engine
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Run `npx trigger.devlatest dev` to start the Trigger.dev development server
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Run `npx trigger.devlatest init` to initialize a Trigger.dev project
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Specify runtime environment (node or bun) in trigger.config.ts using the `runtime` property
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use the `task()` function from `trigger.dev/sdk/v3` to define tasks with id and run properties
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/app/**/*.{ts,tsx} : Access all environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env` in the Trigger.dev webapp
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `.withStreams()` to subscribe to realtime streams from task metadata in addition to run changes
Applied to files:
packages/cli-v3/src/entryPoints/dev-run-worker.tspackages/cli-v3/src/entryPoints/managed-run-worker.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Use the Run Engine 2.0 from `internal/run-engine` for new run lifecycle code in the webapp instead of the legacy run engine
Applied to files:
packages/cli-v3/src/entryPoints/managed-run-worker.ts
🧬 Code graph analysis (3)
packages/cli-v3/src/entryPoints/dev-index-worker.ts (1)
packages/cli-v3/src/utilities/sourceMaps.ts (1)
installSourceMapSupport(3-22)
packages/cli-v3/src/entryPoints/managed-index-worker.ts (1)
packages/cli-v3/src/utilities/sourceMaps.ts (1)
installSourceMapSupport(3-22)
packages/cli-v3/src/entryPoints/managed-run-worker.ts (2)
packages/cli-v3/src/utilities/sourceMaps.ts (1)
installSourceMapSupport(3-22)packages/core/src/v3/schemas/build.ts (2)
WorkerManifest(86-111)WorkerManifest(113-113)
🔇 Additional comments (6)
.changeset/fix-sentry-oom-2920.md (1)
1-5: Changeset entry is clear and sufficient.packages/cli-v3/src/utilities/sourceMaps.ts (1)
1-21: Centralized source map setup looks good.packages/cli-v3/src/entryPoints/dev-index-worker.ts (1)
16-23: Source map installer call is wired correctly.packages/cli-v3/src/entryPoints/managed-run-worker.ts (1)
66-69: LGTM on the startup wiring changes.Also applies to: 127-132, 255-262
packages/cli-v3/src/entryPoints/dev-run-worker.ts (1)
66-69: Startup wiring changes look good.Also applies to: 150-151, 279-284
packages/cli-v3/src/entryPoints/managed-index-worker.ts (1)
16-23: Source map installer hook and keep-alive mapping look fine.Also applies to: 167-168
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version" | ||
| })`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n packages/cli-v3/src/entryPoints/dev-run-worker.ts | sed -n '100,110p'Repository: triggerdotdev/trigger.dev
Length of output: 453
Remove the newline and indentation from the process.title template literal.
The template literal on lines 104-105 preserves the newline and two spaces before }), which will be included literally in the process title string, resulting in an unintended multiline title. Keep the closing brace on the same line as the template expression.
🔧 Suggested fix
-process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"
- })`;
+process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version" | |
| })`; | |
| process.title = `trigger-dev-run-worker (${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`; |
🤖 Prompt for AI Agents
In `@packages/cli-v3/src/entryPoints/dev-run-worker.ts` around lines 104 - 105,
The process.title assignment uses a template literal that includes a newline and
spaces before the closing "})", producing an unintended multiline process title;
fix this in the process.title = `trigger-dev-run-worker
(${getEnvVar("TRIGGER_WORKER_VERSION") ?? "unknown version"})`; statement by
moving the closing brace and backtick onto the same line as the template
expression so no newline or extra spaces are included (locate the assignment to
process.title and the getEnvVar call to update).
| import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; | ||
| import sourceMapSupport from "source-map-support"; | ||
| import { installSourceMapSupport } from "./sourceMaps.js"; | ||
|
|
||
| vi.mock("source-map-support", () => ({ | ||
| default: { | ||
| install: vi.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| describe("installSourceMapSupport", () => { | ||
| const originalEnv = process.env; | ||
| const originalSetSourceMapsEnabled = process.setSourceMapsEnabled; | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| process.env = { ...originalEnv }; | ||
| // Mock setSourceMapsEnabled if it doesn't exist (Node < 16.6) or restore it | ||
| process.setSourceMapsEnabled = vi.fn(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| process.env = originalEnv; | ||
| process.setSourceMapsEnabled = originalSetSourceMapsEnabled; | ||
| }); | ||
|
|
||
| it("should install source-map-support by default (undefined env var)", () => { | ||
| delete process.env.TRIGGER_SOURCE_MAPS; | ||
| installSourceMapSupport(); | ||
| expect(sourceMapSupport.install).toHaveBeenCalledWith({ | ||
| handleUncaughtExceptions: false, | ||
| environment: "node", | ||
| hookRequire: false, | ||
| }); | ||
| }); | ||
|
|
||
| it("should install source-map-support if env var is 'true'", () => { | ||
| process.env.TRIGGER_SOURCE_MAPS = "true"; | ||
| installSourceMapSupport(); | ||
| expect(sourceMapSupport.install).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("should NOT install source-map-support if env var is 'false'", () => { | ||
| process.env.TRIGGER_SOURCE_MAPS = "false"; | ||
| installSourceMapSupport(); | ||
| expect(sourceMapSupport.install).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("should NOT install source-map-support if env var is '0'", () => { | ||
| process.env.TRIGGER_SOURCE_MAPS = "0"; | ||
| installSourceMapSupport(); | ||
| expect(sourceMapSupport.install).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("should enable native node source maps if env var is 'node'", () => { | ||
| process.env.TRIGGER_SOURCE_MAPS = "node"; | ||
| installSourceMapSupport(); | ||
| expect(sourceMapSupport.install).not.toHaveBeenCalled(); | ||
| expect(process.setSourceMapsEnabled).toHaveBeenCalledWith(true); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Find and read the source file being tested
find . -path "*packages/cli-v3/src/utilities/sourceMaps.ts" -o -path "*packages/cli-v3/src/utilities/sourceMaps.js" | head -5Repository: triggerdotdev/trigger.dev
Length of output: 114
🏁 Script executed:
# Check the full CLAUDE.md and AGENTS.md for context on mocking policy
find . -name "CLAUDE.md" -o -name "AGENTS.md" | head -5Repository: triggerdotdev/trigger.dev
Length of output: 92
🏁 Script executed:
# Search for any mocking guidance in documentation files
rg "mock|testcontainers" --type md -A 3 -B 1 | head -100Repository: triggerdotdev/trigger.dev
Length of output: 3907
🏁 Script executed:
cat -n ./packages/cli-v3/src/utilities/sourceMaps.tsRepository: triggerdotdev/trigger.dev
Length of output: 751
🏁 Script executed:
# Check if there are any other test files in the repo that mock third-party libraries to understand the policy scope
rg "vi\.mock|vi\.spyOn" --type ts -l packages/ | head -10Repository: triggerdotdev/trigger.dev
Length of output: 286
🏁 Script executed:
# Check one of these other test files to see if they also mock, and if so, whether this is a systemic issue or expected
cat -n packages/core/src/v3/serverOnly/shutdownManager.test.ts | head -80Repository: triggerdotdev/trigger.dev
Length of output: 3373
🏁 Script executed:
# Search for any tests that DON'T mock to understand how they structure tests for external dependencies
rg "describe\(" packages/cli-v3/src/utilities/sourceMaps.test.ts -A 30 | head -50Repository: triggerdotdev/trigger.dev
Length of output: 1179
🏁 Script executed:
# Check if there are any recent commits or guidance about this specific test file
git log --oneline packages/cli-v3/src/utilities/sourceMaps.test.ts | head -5Repository: triggerdotdev/trigger.dev
Length of output: 160
🏁 Script executed:
# Check if there are any tests in the repo that test source-map behavior without mocking
rg "source-map|sourceMap" --type ts packages/ | grep -E "\.test\.|\.spec\." | head -10Repository: triggerdotdev/trigger.dev
Length of output: 1205
🏁 Script executed:
# Look for any test files that might show patterns for testing environment-dependent code
rg "process\.env" --type ts packages/*/src/**/*.test.ts | head -10Repository: triggerdotdev/trigger.dev
Length of output: 820
Remove all mocking from this test file; this violates the repository's explicit "never mock anything" policy.
The test uses vi.mock("source-map-support") and vi.fn() to stub process.setSourceMapsEnabled, which directly contradicts the repository's documented testing standards. Per CLAUDE.md and ai/references/tests.md, mocking, spying, and stubbing are forbidden in tests.
Refactor installSourceMapSupport to be more testable without mocks—for example, by extracting the logic into separate, pure functions that can be tested with real values, or by redesigning the function to accept dependencies as parameters. Alternatively, if testing the actual behavior of source-map-support is necessary, consider writing an integration test that exercises the real module without mocks.
🤖 Prompt for AI Agents
In `@packages/cli-v3/src/utilities/sourceMaps.test.ts` around lines 2 - 61, The
tests violate the no-mocking policy: remove vi.mock("source-map-support") and
any vi.fn() stubs for process.setSourceMapsEnabled from
packages/cli-v3/src/utilities/sourceMaps.test.ts and instead refactor
installSourceMapSupport to accept its dependencies (e.g., a sourceMapSupport
object with an install method and an optional setSourceMapsEnabled function) or
to expose pure helper functions for the decision logic; update the tests to call
those pure functions or pass real dependency objects (or use an integration test
hitting the real source-map-support) and assert behavior without creating mocks
or spies against source-map-support or process.setSourceMapsEnabled.
Summary
Fixes #2920
Problem
Sentry sourcemap injection adds
ew Error().stack\ to bundled modules, causing \source-map-support\ to eagerly parse sourcemaps during module loading. This leads to OOM on small machines when bundling many files.
Fix
Wrapped \sourceMapSupport.install()\ logic in \installSourceMapSupport\ utility across all worker entry points.
Introduced \TRIGGER_SOURCE_MAPS\ environment variable: